//模板特例化, 所谓特例，是值类型特例
#include <iostream>
#include <deque>
#include <stdexcept>
#include "stack1.hpp"

using namespace std;

template <>
class Stack<std::string>{
private:
    std::deque<std::string> elems;
    
public:
    void push(std::string const& );

    void pop();

    std::string top() const;

    bool empty() const {
        return elems.empty();
    }
};

void Stack<std::string>::push(std::string const& elem) 
{
    elems.push_back(elem);
}

void Stack<std::string>::pop() 
{
    if (elems.empty()) {
        throw std::out_of_range("Stack<>::pop(); empty stack");
    }
    elems.pop_back();
}

std::string Stack<std::string>::top() const 
{
    if (elems.empty()) {
        throw std::out_of_range("Stack<>::pop(); empty stack");
    }
    return elems.back();
}

